package com.qfedu.openapi.web.master.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.openapi.web.master.dao.application.ApplicationDao;
import com.qfedu.openapi.web.master.entity.Application;
import com.qfedu.openapi.web.master.service.ApplicationService;
import com.qfedu.openapi.web.master.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("/applicationService")
public class ApplicationServiceImpl implements ApplicationService {

    @Autowired
    private ApplicationDao applicationDao;
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public PageInfo<Application> findAllApplicationUser(PageVo pageVo) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<Application> Application = applicationDao.findAllApplicationUser();
        return new PageInfo<Application>(Application);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public PageInfo<Application> findAllApplicationUser(PageVo pageVo, Application application) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<Application> applicationUsers = applicationDao.findAllApplicationUsersByCondition(application);
        return new PageInfo<Application>(applicationUsers);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer addApplicationuser(Application application) {
        return applicationDao.insertApplicationuser(application);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer delApplicationuser(Integer[] ids) {
        return applicationDao.deleteApplicationuser(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer updateApplicationuser(Application application) {
        return applicationDao.updateApplicationuser(application);
    }
}
